package demo8;

import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        while (input.hasNextLine()) {
            String str = input.nextLine();
            TreeNode root = createTree(str);
            inorder(root);
        }
    }
    public static int i = 0;
    public static TreeNode createTree(String str) {
        TreeNode root = new TreeNode(str.charAt(i));
        if (str.charAt(i) == '#') {
            i++;
            return null;
        }
        i++;
        root.left = createTree(str);
        root.right = createTree(str);
        return root;
    }
    //中序遍历
    public static void inorder(TreeNode root) {
        if (root == null) {
            return;
        }
        inorder(root.left);
        System.out.print(root.val + " ");
        inorder(root.right);
    }
}
